<template>
	<div style="background-color: #FFFFFF; width: 100%; height: 100%; padding: 15px;">
		<div style="margin-left: 26px; font-size: 13px; font-weight: bold;">
			<span>耗电报表</span>
		</div>
		<div style="margin-left: 20px;margin-top: 20px;  ">
			<a-row :gutter="16">
				<a-col :span="6">
					<j-dict-select-tag style="width: 100%" placeholder="请选择公司" v-model="selectQuery.company"
						dictCode="crm_company,name,id" disabled />
				</a-col>
				<a-col :span="6">
					<j-dict-select-tag style="width: 100%" placeholder="请选择车间" v-model="selectQuery.workshop"
						dictCode="workshop" />
				</a-col>
				<a-col :span="6">
					<j-dict-select-tag style="width: 100%" placeholder="请选择工序" v-model="selectQuery.productCategory"
						dictCode="product_category" />
				</a-col>
				<a-col :span="6">
					 <a-input placeholder="请输入品种"  v-model="selectQuery.productTypeTxt" @blur="getElectricityMonthChartData"/>
					<!-- <j-dict-select-tag v-if="processParam == 'QingHua'" placeholder="请选择品种" v-model="selectQuery.productType"
						@change="changePz" dictCode="crm_product_type_blowing,product_type,id" />
					<j-dict-select-tag v-if="processParam == 'ShuMian'" placeholder="请选择品种" v-model="selectQuery.productType"
						@change="changePz" dictCode="crm_product_type_cotton,product_type,id" />
					<j-dict-select-tag v-if="processParam == 'BingTiao'" placeholder="请选择品种" v-model="selectQuery.productType"
						@change="changePz" dictCode="crm_product_type_drawing,product_type,id" />
					<j-dict-select-tag v-if="processParam == 'CuSha'" placeholder="请选择品种" v-model="selectQuery.productType"
						@change="changePz" dictCode="crm_product_type_rove,product_type,id" />
					</a-form-model-item> -->
					<!-- <j-dict-select-tag style="width: 100%" placeholder="请选择品种" v-model="selectQuery.productCategory"
						dictCode="product_category" /> -->
				</a-col>

				<!-- <a-col :span="6">
					<a-select style="width: 100%" placeholder="请选择机台" v-model="selectQuery.deviceNo"
						:key="selectQuery.productCategory">
						<a-select-option v-for="(item,index) in deviceList" :key="index" :value="item.deviceNo">
							{{ item.workingProcedure_dictText }}{{ item.deviceNo }}
						</a-select-option>
					</a-select>
				</a-col> -->

				<a-col :span="6">
					<!-- <RangePicker v-model="queryTime" @change="onChange"></RangePicker> -->
					<a-date-picker style="margin-top: 10px;" :format="'YYYY/MM/DD'" v-model="queryTime"
						@change="onChange" />
				</a-col>

				<a-col :span="2">
<!-- 					<a-button @click="getElectricityMonthChartData" type="primary" style="margin-top: 10px">
						查询
					</a-button> -->
					
					<a-button @click="ExportLengthReport('耗电日报表')" type="primary" style="margin-left: 20px; margin-top: 10px;">
						导出
					</a-button>
				</a-col>
			</a-row>

			<div>
				<div style="margin-top: 30px;">
					<a-table :columns="columns" :data-source="dataSource" :loading="loading" :rowClassName="setRowClassName"   :scroll="{ y: 450 }" :pagination="false">
						<span slot="deviceIdsTxt"
							slot-scope="deviceIdsTxt">{{ devName }}{{ getSeiresDevsn(deviceIdsTxt) }}</span>
						<span slot="efficiency" slot-scope="text">{{ (Number(text) * 100).toFixed(2) }}%</span>
						<span slot="currentActualOutput" slot-scope="text">{{ Number(text).toFixed(2) }}</span>
						<span slot="consumption" slot-scope="text">{{ Number(text).toFixed(2) }}</span>
						<span slot="consumptionPerTon" slot-scope="text">{{ Number(text).toFixed(2) }}</span>
					</a-table>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import * as echarts from 'echarts'
	import {
		getAction
	} from '@/api/manage'
	import moment from 'moment'
	import RangePicker from '@/components/RangePicker/RangePicker.vue'
	import request from '@/api/request'
	import { downFile } from '@/api/manage'
	export default {
		components: {
			RangePicker
		},
		data() {
			return {
				loading: true,
				tableData: [],
				url: {
					processDetailsConsumptionDay: '/ds_device_real_time_status/dsDeviceRealTimeStatus/processDetailsConsumptionDay', // 耗电日报
					processDetailsConsumptionMonth: '/ds_consumption_month/dsConsumptionMonth/list', // 耗电月报
					exportLengthXlsUrl:'/ds_consumption_month/dsConsumptionMonth/exportXls'
				},
				queryTime: moment(new Date(), 'YYYY-MM-DD'),
				labelCol: {
					xs: {
						span: 4
					},
					sm: {
						span: 6
					}
				},
				wrapperCol: {
					xs: {
						span: 20
					},
					sm: {
						span: 18
					}
				},
				// 查询条件
				selectQuery: {
					// 公司
					company: '1771136798305476610',
					// 车间
					workshop: '2',
					// 工序
					productCategory: '1',
					// 机台号
					deviceNo: undefined,
					// 开始时间
					startTime: undefined,
					// 结束时间
					endTime: undefined,
					
					productTypeTxt:'',
					
					pageSize: -1
				},
				gxOption1: [],
				// 设备机台
				deviceList: [],
				// 显示工序和机台的对应关系
				/*
				* productCategory（细纱1；粗纱2；头并4；末并5；梳棉6；抓棉7；多仓8；精开棉9；络筒10；打包11）
				  workingProcedure（清花1；梳棉2；并条4；粗纱5；细纱6；络筒7；打包8；）
				  清花对应：抓棉、多仓、精开棉；并条对应：头并、末并
				* */
				workingProcedure: {
					// 细纱1 -> 细纱6
					1: 6,
					// 粗纱2 -> 粗纱5
					2: 5,
					// 抓棉7 -> 清花1
					7: 1,
					// 多仓8 -> 清花1
					8: 1,
					// 精开棉9 -> 清花1
					9: 1,
					// 头并4 -> 并条4
					4: 4,
					//末并5 -> 并条4
					5: 4,
					// 梳棉6  -> 梳棉2
					6: 2,
					// 络筒10  -> 络筒7
					10: 2,
					// 打包11 -> 打包8
					11: 8
				},
				devName: '',
				dataSource: [],
				columns: [
				  {
				    title: '日期',
				    dataIndex: 'planTime',
				    key: 'planTime'
				  },
				  {
				    title: '车间',
				    dataIndex: 'workshop_dictText',
				    key: 'workshop'
				  },
				  {
				    title: '品种',
				    title: () => (
				      <div>
				        品种
				        <a-icon type="caret-up" class="sort-icon" onClick={() => this.tableSort('productTypeTxt', 'ascend')} />
				        <a-icon type="caret-down" class="sort-icon" onClick={() => this.tableSort('productTypeTxt', 'descend')} />
				      </div>
				    ),
				    dataIndex: 'productTypeTxt',
				    key: 'productTypeTxt'
				  },
				  {
				    // title: '车台号',
				    title: () => (
				      <div>
				        车台号
				        <a-icon type="caret-up" class="sort-icon" onClick={() => this.tableSort('deviceIdsTxt', 'ascend')} />
				        <a-icon type="caret-down" class="sort-icon" onClick={() => this.tableSort('deviceIdsTxt', 'descend')} />
				      </div>
				    ),
				    dataIndex: 'deviceIdsTxt',
				    key: 'deviceIdsTxt',
				    scopedSlots: { customRender: 'deviceIdsTxt' }
				  },
				  {
				    // title: '产量(米)',
				    title: () => (
				      <div>
				        产量(米)
				        <a-icon
				          type="caret-up"
				          class="sort-icon"
				          // style={{ color: this.sortColumn === 'length' && this.sortOrder === 'ascend' ? '#1890ff' : '#bfbfbf' }}
				          onClick={() => this.tableSort('length', 'ascend')}
				        />
				        <a-icon
				          type="caret-down"
				          class="sort-icon"
				          // style={{ color: this.sortColumn === 'length' && this.sortOrder === 'descend' ? '#1890ff' : '#bfbfbf' }}
				          onClick={() => this.tableSort('length', 'descend')}
				        />
				      </div>
				    ),
				    dataIndex: 'length',
				    key: 'length'
				  },
				  {
				    title: '当前实际产量(kg)',
				    title: () => (
				      <div>
				        当前实际产量(kg)
				        <a-icon
				          type="caret-up"
				          class="sort-icon"
				          onClick={() => this.tableSort('currentActualOutput', 'ascend')}
				        />
				        <a-icon
				          type="caret-down"
				          class="sort-icon"
				          onClick={() => this.tableSort('currentActualOutput', 'descend')}
				        />
				      </div>
				    ),
				    dataIndex: 'currentActualOutput',
				    key: 'currentActualOutput',
				    scopedSlots: { customRender: 'currentActualOutput' }
				  },
				  {
				    // title: '耗电量(kw/h)',
				    title: () => (
				      <div>
				        耗电量(kw/h)
				        <a-icon type="caret-up" class="sort-icon" onClick={() => this.tableSort('consumption', 'ascend')} />
				        <a-icon type="caret-down" class="sort-icon" onClick={() => this.tableSort('consumption', 'descend')} />
				      </div>
				    ),
				    dataIndex: 'consumption',
				    key: 'consumption',
				    scopedSlots: { customRender: 'consumption' }
				  },
				  {
				    // title: '吨纱电耗(kw/吨)',
				    title: () => (
				      <div>
				        吨纱电耗(kw/吨)
				        <a-icon type="caret-up" class="sort-icon" onClick={() => this.tableSort('consumptionPerTon', 'ascend')} />
				        <a-icon
				          type="caret-down"
				          class="sort-icon"
				          onClick={() => this.tableSort('consumptionPerTon', 'descend')}
				        />
				      </div>
				    ),
				    dataIndex: 'consumptionPerTon',
				    key: 'consumptionPerTon',
				    scopedSlots: { customRender: 'consumptionPerTon' }
			}]
		}
		},
		mounted() {
			// this.getEchartsData()
			this.getElectricityMonthChartData()
		},
		watch: {
			'selectQuery.workshop'() {
				this.getElectricityMonthChartData()
			},
			'selectQuery.productCategory'() {
				this.getElectricityMonthChartData()
			},
			// 'selectQuery.deviceNo'() {
			// 	this.getElectricityMonthChartData()
			// },
			selectQuery: {
				handler() {
					const data = Object.keys(this.selectQuery)
					for (let i = 0; i < data.length; i++) {
						if (!this.selectQuery[data[i]]) {
							return
						}
					}
					this.onSearch()
				},
				deep: true
			},
			//筛选tableData
			tableData: {
			    immediate: true,
			    handler(newVal, oldVal) {
			      this.dataSource = newVal
			    },
			    deep: true
			}
		},
		methods: {
			searchQuery(){
				this.getElectricityMonthChartData()
			},
			ExportLengthReport(fileName) {
			  var time = this.msToDate(this.queryTime._d).withoutTime
			  var param = {
			  		company: this.selectQuery.company,
			  		workshop: this.selectQuery.workshop,
			  		productCategory: this.selectQuery.productCategory,
			  		// workingProcedure: 6,
			  		pageNo: 1,
			  		pageSize: -1,
			  		planTime:time,
			  		productTypeTxt:this.selectQuery.productTypeTxt == '' ? '' : '*'+this.selectQuery.productTypeTxt+'*'
			  	}
			  downFile(this.url.exportLengthXlsUrl, param).then(data => {
			    if (!data) {
			      this.$message.warning('文件下载失败')
			      return
			    }
			    if (typeof window.navigator.msSaveBlob !== 'undefined') {
			      window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
			    } else {
			      let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
			      let link = document.createElement('a')
			      link.style.display = 'none'
			      link.href = url
			      link.setAttribute('download', fileName + '.xls')
			      document.body.appendChild(link)
			      link.click()
			      document.body.removeChild(link) //下载完成移除元素
			      window.URL.revokeObjectURL(url) //释放掉blob对象
			    }
			  })
			},
			msToDate(msec) {
				let datetime = new Date(msec);
				let year = datetime.getFullYear();
				let month = datetime.getMonth();
				let date = datetime.getDate();
				let hour = datetime.getHours();
				let minute = datetime.getMinutes();
				let second = datetime.getSeconds();

				let result1 = year +
					'-' +
					((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) +
					'-' +
					((date + 1) < 10 ? '0' + date : date) +
					' ' +
					((hour + 1) < 10 ? '0' + hour : hour) +
					':' +
					((minute + 1) < 10 ? '0' + minute : minute) +
					':' +
					((second + 1) < 10 ? '0' + second : second);

				let result2 = year +
					'-' +
					((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) +
					'-' +
					((date + 1) < 10 ? '0' + date : date);

				let result = {
					hasTime: result1,
					withoutTime: result2
				};

				return result;
			},
			// 耗电报表请求月报
			getElectricityMonthChartData() {
				var time = this.msToDate(this.queryTime._d).withoutTime
				getAction(this.url.processDetailsConsumptionDay, {
						company: this.selectQuery.company,
						workshop: this.selectQuery.workshop,
						productCategory: this.selectQuery.productCategory,
						// workingProcedure: 6,
						pageNo: 1,
						pageSize: -1,
						planTime:time,
						productTypeTxt:this.selectQuery.productTypeTxt
					})
					.then(res => {
						if (res.code == 200) {
							this.loading = false
							this.tableData = res.result.records
						} else {
							this.loading = false
							this.$message.error('请求失败')
						}
					})
					.catch(err => {
						this.loading = false
					})
			},
			getDeviceList() {
				this.selectQuery.deviceNo = undefined
				this.deviceList = []
				// 车间和工序都选才去查询
				if (!this.selectQuery.workshop || !this.selectQuery.productCategory) {
					return
				}
				const params = {
					workshop: this.selectQuery.workshop,
					workingProcedure: this.workingProcedure[this.selectQuery.productCategory],
					pageSize: -1
				}
				getAction('/crm_device/crmDevice/list', params).then(res => {
					this.deviceList = res.result.records
				})
			},
			onSearch() {

			},

			onChange() {
				console.log(this.queryTime, 'this.queryTime?????')
				console.log('改变了数据')
				// this.selectQuery.startTime = this.queryTime[0]
				// this.selectQuery.endTime = this.queryTime[1]
				this.getElectricityMonthChartData()
			},
			// 获取连续车台
			getSeiresDevsn(arr) {
			  arr = arr.split(',')
			  var result = [],
			    i = 0,
			    str = ''
			  if (arr.length > 0) {
			    result[i] = [arr[0]]
			    arr.reduce(function(prev, cur) {
			      parseInt(cur) - parseInt(prev) === 1 ? result[i].push(cur) : (result[++i] = [cur])
			      return cur
			    })
			    result.map(item => {
			      if (item.length > 1) {
			        str += `${item[0]}-${item[item.length - 1]}、`
			      } else {
			        str += `${item[0]}、`
			      }
			    })
			    str = str.substring(0, str.length - 1)
			  } else {
			    str = ''
			  }
			  return str
			},
			// 根据name判断排序的列，根据order判断排序规则
			tableSort(name, order) {
			  //删除拼接id的条目
			  this.dataSource = this.dataSource.filter(item => !item.isStatistics)
			  //根据规则排序
			  const sortedData = [...this.dataSource].sort((a, b) => {
			    switch (name) {
			      case 'productTypeTxt':
			        return order === 'ascend'
			          ? a.productTypeTxt.localeCompare(b.productTypeTxt)
			          : b.productTypeTxt.localeCompare(a.productTypeTxt)
			      case 'length':
			        return order === 'ascend' ? a.length - b.length : b.length - a.length
			      case 'deviceIdsTxt':
			        return order === 'ascend'
			          ? parseInt(a.deviceIdsTxt) - parseInt(b.deviceIdsTxt)
			          : parseInt(b.deviceIdsTxt) - parseInt(a.deviceIdsTxt)
			      case 'currentActualOutput':
			        return order === 'ascend'
			          ? a.currentActualOutput - b.currentActualOutput
			          : b.currentActualOutput - a.currentActualOutput
			      case 'consumption':
			        return order === 'ascend' ? a.consumption - b.consumption : b.consumption - a.consumption
			      case 'consumptionPerTon':
			        return order === 'ascend'
			          ? a.consumptionPerTon - b.consumptionPerTon
			          : b.consumptionPerTon - a.consumptionPerTon
			      default:
			        return 0
			    }
			  })
			  //排序后调用processData方法将连续序号相同品种的集合对象插入数组，参数是排序后的数组（先排序后插入）
			  this.processData(sortedData)
			},
			processData(sortedData) {
				console.log(sortedData,'console.log(sortedData)?????????')
			  // console.log('执行了processData', sortedData)
			  let result = []
			  let planTime = sortedData[0].planTime
			  let workshop = sortedData[0].workshop
			  let workshop_dictText = sortedData[0].workshop_dictText
			  let lengthSum = 0
			  let currentActualOutputSum = 0
			  let consumptionSum = 0
			  let consumptionPerTonSum = 0
			  let start = null
			  let end = null
			  let currentType = null //品种
			
			  for (let i = 0; i < sortedData.length; i++) {
			    if (start === null) {
			      start = sortedData[i].deviceIdsTxt
			      currentType = sortedData[i].productTypeTxt
			    }
				
			    if (
			      i < sortedData.length - 1 &&
			      sortedData[i + 1].productTypeTxt === currentType &&
			      parseInt(sortedData[i + 1].deviceIdsTxt) === parseInt(sortedData[i].deviceIdsTxt) 
			    ) {
				  console.log('进入判断？？？？？？？1')
			      lengthSum += sortedData[i].length
			      currentActualOutputSum += sortedData[i].currentActualOutput
			      consumptionSum += sortedData[i].consumption
			      consumptionPerTonSum += sortedData[i].consumptionPerTon
			      end = sortedData[i + 1].deviceIdsTxt
			      result.push(sortedData[i])
			    } else {
			      lengthSum += sortedData[i].length
			      currentActualOutputSum += sortedData[i].currentActualOutput
			      consumptionSum += sortedData[i].consumption
			      consumptionPerTonSum += sortedData[i].consumptionPerTon
				  console.log('进入判断？？？？？？？2')
				  console.log(start,'进入判断？？？？？？？2')
				  console.log(end,'进入判断？？？？？？？2')
			      if (start === end) {
			        result.push(sortedData[i])
			        result.push({
			          productTypeTxt: currentType,
			          deviceIdsTxt: `${start}-${end}`,
			          length: lengthSum,
			          planTime: planTime,
			          workshop: workshop,
			          workshop_dictText: workshop_dictText,
			          currentActualOutput: currentActualOutputSum,
			          consumption: consumptionSum,
			          consumptionPerTon: consumptionPerTonSum,
			          isStatistics: true
			        })
			      } else {
			        result.push(sortedData[i])
			      }
			      start = sortedData[i + 1] ? sortedData[i + 1].deviceIdsTxt : null
			      end = null
			      lengthSum = 0
			      currentActualOutputSum = 0
			      consumptionPerTonSum = 0
			      consumptionSum = 0
			      currentType = sortedData[i + 1] ? sortedData[i + 1].productTypeTxt : null
			    }
			  }
			
			  let delIndexDefault = [] // 存放需要删除的索引值默认值
			  let delIndex = [] // 存放需要删除的索引值（筛选后）
			  let statisticsArr = [] // 存放需要操作的对象
			  let newStatisticsArr = [] // 存放修改后的新对象
			
			  result.forEach((item, index) => {
			    if (item.isStatistics === true) {
			      item.index = index // 多存入索引值用于区分需要被删除的对象的索引值
			      delIndexDefault.push(index)
			      statisticsArr.push(item)
			    }
			  })
			  //二次处理数组，合并连续品种的不同连续机台
			  let planTime2 = sortedData[0].planTime
			  let workshop2 = sortedData[0].workshop
			  let workshop_dictText2 = sortedData[0].workshop_dictText
			  let lengthSum2 = 0
			  let currentActualOutputSum2 = 0
			  let consumptionSum2 = 0
			  let consumptionPerTonSum2 = 0
			  let deviceIdsTxt2 = ''
			  let currentType2 = null //品种
			  let index2 = -1
			  // 拼接生成连续品种不同机台数组
			  for (let i = 0; i < statisticsArr.length; i++) {
			    // 如果不是最后一项（因为最后一项没有i+1）
				console.log(statisticsArr)
			    if (i < statisticsArr.length - 1) {
			      // 如果和后一项相同就累加
			      if (statisticsArr[i].productTypeTxt == statisticsArr[i + 1].productTypeTxt) {
			        deviceIdsTxt2 = `${deviceIdsTxt2};${statisticsArr[i].deviceIdsTxt}`
			        lengthSum2 = lengthSum2 += statisticsArr[i].length
			        currentActualOutputSum2 = currentActualOutputSum2 += statisticsArr[i].currentActualOutput
			        consumptionSum2 = consumptionSum2 += statisticsArr[i].consumption
			        consumptionPerTonSum2 = consumptionPerTonSum2 += statisticsArr[i].consumptionPerTon
			      }
			      // 如果和后一项不相同就累加后压入数组，然后初始化暂存
			      else {
			        deviceIdsTxt2 = `${deviceIdsTxt2};${statisticsArr[i].deviceIdsTxt}`
			        lengthSum2 = lengthSum2 += statisticsArr[i].length
			        currentActualOutputSum2 = currentActualOutputSum2 += statisticsArr[i].currentActualOutput
			        consumptionSum2 = consumptionSum2 += statisticsArr[i].consumption
			        consumptionPerTonSum2 = consumptionPerTonSum2 += statisticsArr[i].consumptionPerTon
			        currentType2 = statisticsArr[i].productTypeTxt
			        index2 = statisticsArr[i].index
			        newStatisticsArr.push({
			          productTypeTxt: currentType2,
			          deviceIdsTxt: deviceIdsTxt2,
			          length: lengthSum2,
			          planTime: planTime2,
			          workshop: workshop2,
			          workshop_dictText: workshop_dictText2,
			          currentActualOutput: currentActualOutputSum2,
			          consumption: consumptionSum2,
			          consumptionPerTon: consumptionPerTonSum2,
			          isStatistics: true,
			          index: index2
			        })
			        lengthSum2 = 0
			        currentActualOutputSum2 = 0
			        consumptionSum2 = 0
			        consumptionPerTonSum2 = 0
			        deviceIdsTxt2 = ''
			        currentType2 = null //品种
			        index2 = -1
			      }
			    }
			    // 如果是最后一项
			    else {
			      // 如果与前一项不相同就直接压入自己
			      if (statisticsArr[i].productTypeTxt != statisticsArr[i - 1].productTypeTxt) {
			        newStatisticsArr.push({
			          productTypeTxt: statisticsArr[i].productTypeTxt,
			          deviceIdsTxt: statisticsArr[i].deviceIdsTxt,
			          length: statisticsArr[i].length,
			          planTime: planTime2,
			          workshop: workshop2,
			          workshop_dictText: workshop_dictText2,
			          currentActualOutput: statisticsArr[i].currentActualOutput,
			          consumption: statisticsArr[i].consumption,
			          consumptionPerTon: statisticsArr[i].consumptionPerTon,
			          isStatistics: true,
			          index: statisticsArr[i].index
			        })
			      }
			      // 如果与前一项相同就累加后压入自己
			      else if (statisticsArr[i].productTypeTxt == statisticsArr[i - 1].productTypeTxt) {
			        deviceIdsTxt2 = `${deviceIdsTxt2};${statisticsArr[i].deviceIdsTxt}`
			        lengthSum2 = lengthSum2 += statisticsArr[i].length
			        currentActualOutputSum2 = currentActualOutputSum2 += statisticsArr[i].currentActualOutput
			        consumptionSum2 = consumptionSum2 += statisticsArr[i].consumption
			        consumptionPerTonSum2 = consumptionPerTonSum2 += statisticsArr[i].consumptionPerTon
			        currentType2 = statisticsArr[i].productTypeTxt
			        index2 = statisticsArr[i].index
			        newStatisticsArr.push({
			          productTypeTxt: currentType2,
			          deviceIdsTxt: deviceIdsTxt2,
			          length: lengthSum2,
			          planTime: planTime2,
			          workshop: workshop2,
			          workshop_dictText: workshop_dictText2,
			          currentActualOutput: currentActualOutputSum2,
			          consumption: consumptionSum2,
			          consumptionPerTon: consumptionPerTonSum2,
			          isStatistics: true,
			          index: index2
			        })
			      }
			    }
			  }
			  // 去除因为拼接生成的第一个分号'；'
			  newStatisticsArr.forEach(item => {
			    if (item.deviceIdsTxt.includes(';')) {
			      item.deviceIdsTxt = item.deviceIdsTxt.replace(';', '')
			    }
			    // 覆盖掉result里面的
			    result[item.index] = item
			  })
			  // 筛选出要被删除的索引值,创建用于删除的索引数组
			  delIndexDefault.forEach(item => {
			    if (!newStatisticsArr.some(obj => obj.index == item)) {
			      delIndex.push(item)
			    }
			  })
			  result = result.filter((_, index) => !delIndex.includes(index))
			
			  this.dataSource = result
			
			  console.log('this.dataSourceresres', this.dataSource)
			},
			setRowClassName(record) {
			  return record.isStatistics == true ? 'red-row' : ''
			}
		}
}
</script>

<style lang="less" scoped>
	.graph {
		width: 100%;

		height: 70vh;
	}

	/deep/ .ant-col-6 {
		width: 21.7%;
	}
	
	/deep/ .red-row {
	  color: red !important;
	}
</style>